import java.awt.Graphics2D;
import java.util.Vector;

/**
 * Class for creating a free-form drawing 
 * 
 * @author Chia-Chi (Teresa) Lee
 */
public class FreeForm extends MyShape {
  
  //For storing all points
  
  private Vector xPoints = new Vector();
  private Vector yPoints = new Vector();
  
  public FreeForm(int x_s, int y_s){
    xPoints.add(x_s);
    yPoints.add(y_s);
  }
  
  /**
   * Method for adding points to the Vector
   * 
   */
  @Override
  public void setX_e(int x_e){
    xPoints.add(x_e);
  };
  
  /**
   * Method for adding points to the Vector
   * 
   */
  @Override
  public void setY_e(int y_e){
    yPoints.add(y_e);
  };
  
  /**
   * Method for drawing the free-form shape
   * 
   */
  public void drawMe(Graphics2D g, int screenWidth, int screenHeight) {
    for(int i=0; i<xPoints.size()-1;i++){
        g.drawLine((int)xPoints.get(i),(int)yPoints.get(i),(int)xPoints.get(i+1),(int)yPoints.get(i+1));
    }
  }
  
  /**
   * Get the bottom right point of the bounding box
   * 
   * @return the x coordinate
   */
  public int getRightMost(){
    int max = 0;
    for(int i=0; i<xPoints.size();i++){
      if(max < (int)xPoints.get(i))
        max = (int)xPoints.get(i);
    }
    return max;
  }
  
  /**
   * Get the bottom right point of the bounding box
   * 
   * @return the y coordinate
   */
  public int getBottomMost(){
    int max = 0;
    for(int i=0; i<yPoints.size();i++){
      if(max < (int)yPoints.get(i))
        max = (int)yPoints.get(i);
    }
    return max;
  }
  
}